/*
 * @Description: 
 * @Author: changqing
 * @Date: 2021-08-16 15:57:18
 * @LastEditTime: 2021-08-16 15:57:47
 * @LastEditors: changqing
 * @Usage: 
 */
function* makeSimpleGenerator(array) {
  let nextIndex = 0;
  while (nextIndex < array.length) {
    yield array[nextIndex++];
  }
}

const gen = makeSimpleGenerator(['yo', 'ya']);

console.log(gen.next().value); // 'yo'
console.log(gen.next().value); // 'ya'
console.log(gen.next().done);  // true